package  
{
	
	import flash.display.DisplayObject;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.geom.Rectangle;
	import flash.net.URLRequest;
	/**
	 * ...
	 * @author me
	 */
	public class ClEnemyMissle extends ClObject
	{		
		public var HostObject:ClEnemy;
		public var Target:ClObject;
		
		public function ClEnemyMissle(host:ClEnemy) 
		{
			super(host.stageRef);
			HostObject = host;
			Target = host.targetObject;
			if (Main.useEmbededContent)
				LoadEmbededImage(Assets.EnemyLaserImage);
			else
				LoadImage("../content/images/enemy_laser.png");
		}
		
		/* Вызывается после загрузки картинки */
		protected override function InitParams():void
		{
			//var hostSpeed:int = Math.abs(Math.round(HostObject.ySpeed));
			//if (speed<hostSpeed) 
				//speed = hostSpeed;
		}
		
		override public function removeSelf():void 
		{
			super.removeSelf();
			//removeEventListener(Event.ENTER_FRAME, update);
			Target = null;
			HostObject = null;
		}
		
		
		/* Апдейт */
		protected override function update(e:Event):void
		{
			//if (isDead)	return;
			y += speedPower;
			//x += xSpeed;
			if (y > stageRef.stageHeight + 20)
			{
				removeSelf();
				return;
			}
			

			if (tarArea.hitTestObject(Target.tarArea))
			{
				this.removeSelf();
				return;
			}
		}
		
	}

}